home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
e
/
misc.save
/
000057_fdc@panix.com_Fri Jan 19 13:28:41 2007.msg
< prev
next >
Wrap
Internet Message Format
|
2011-07-03
|
2KB
Path: reader2.panix.com!reader1.panix.com!panix!not-for-mail
From: Frank da Cruz <fdc@panix.com>
Newsgroups: comp.protocols.kermit.misc
Subject: Re: fixed character length with a non-consistant variable length
Date: Fri, 19 Jan 2007 18:28:31 +0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Lines: 42
Message-ID: <slrner23eg.nl5.fdc@panix2.panix.com>
References: <qw_rh.2669$1x.45556@ursa-nb00s0.nbnet.nb.ca>
Reply-To: fdc@columbia.edu
NNTP-Posting-Host: panix2.panix.com
X-Trace: reader2.panix.com 1169231311 16272 166.84.1.2 (19 Jan 2007 18:28:31 GMT)
X-Complaints-To: abuse@panix.com
NNTP-Posting-Date: Fri, 19 Jan 2007 18:28:31 +0000 (UTC)
User-Agent: slrn/0.9.8.0 (NetBSD)
Xref: panix comp.protocols.kermit.misc:15629
On 2007-01-19, Scott Caissie <scottac@nb.sympatico.ca> wrote:
:
: I'm looking for a "simplier" way to force a variable of mixed character
: length to a fixed character length.
:
: For this project, I always want to have MORE characters than the actual
: variable's size. So I'm trying to add in spaces. Thats my problem. Making
: it less is easy.
:
: Example from my project:
: .q_formatted := \fstripx(\fsubstr(\m(getdata),1,13),\9)
: The saved value has up to 13 characters, but mostly it has less. For
: testing purposes, I'm trying to fixate the saved character length to 20.
:
You can use \flpad() ("Left Pad") and/or \frpad() ("Right Pad") for this.
For example, suppose that if a string "foo" is less than 20 bytes long, you
want to fill it out on the right with underscores:
.foo := .\frpad(\m(foo),20,_)
If the string already is 20 or more bytes long, nothing happens to it.
To fill the string out with spaces, use either one of these forms:
.foo := .\frpad(\m(foo),20,\32)
.foo := .\frpad(\m(foo),20)
: The reasoning for doing this, is that I want to save a multitude of values
: into 1 entry within an Array. And by it's character position, other macros
: can determine what the value is represents.
:
You might find some of the programming and data-type extensions presented
here to be useful:
http://www.columbia.edu/kermit/ckscripts.html#oops
For example this one:
ftp://kermit.columbia.edu/kermit/scripts/ckermit/matrix
shows how to create and use multidimensional arrays.
- Frank